using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace WPCoco.Tasks
{
    public class FadeTo : TargetedTask<IColored>
    {
        public FadeTo(Color color, float duration)
            : base(duration)
        {
            this.color = color.ToVector4();
        }

        Vector4 color;
        Vector4 start;
        Vector4 delta;

        public override void InitializeWithTarget(IColored target)
        {
            start = target.Color.ToVector4();
            delta = (color - start) / Duration;
        }

        public override void UpdateWithTarget(IColored target, float time)
        {
            target.Color = new Color(start + delta * time);
        }
    }
}
